//
//  Number(extension).swift
//
//  Created by 董振山 on 2018/4/17.
//  Copyright © 2018年 董振山. All rights reserved.
//

import Foundation
import UIKit
extension Float{
    public var int:Int{
        return Int(self)
    }
    public var double:Double{
        return Double(self)
    }
    public var cgFloat:CGFloat{
        return CGFloat(self)
    }
}
extension Double{
    public var int:Int{
        return Int(self)
    }
    public var float:Float{
        return Float(self)
    }
    public var cgFloat:CGFloat{
        return CGFloat(self)
    }
    public var auto:CGFloat{
        return self.cgFloat / 375.0 * KWIDTH
    }
}
extension Int{
    public var float:Float{
        return Float(self)
    }
    public var double:Double{
        return Double(self)
    }
    public var cgFloat:CGFloat{
        return CGFloat(self)
    }
    public var auto:CGFloat{
        return self.cgFloat / 375.0 * KWIDTH
    }
}
extension CGFloat{
    public var int:Int{
        return Int(self)
    }
    public var double:Double{
        return Double(self)
    }
    public var float:Float{
        return Float(self)
    }
    public var auto:CGFloat{
        return self / 375.0 * KWIDTH
    }
}

extension String{
    public var cgFloat:CGFloat{
        return Double(self)?.cgFloat ?? 0.0
    }
    func double() -> Double{
        return Double(self) == nil ? 0.0 : Double(self)!
    }
    func int() -> Int{
        return self.double().int
    }
    func float() -> Float{
        return self.double().float
    }
}
